<?php
require("../inc/common.inc.php");
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta content="width=device-width,user-scalable=no,initial-scale=1,maximum-scale=1 " name="viewport">
<title>天天刮刮乐-<?php echo $webdb["vpp_jigoucode"]?></title>
<meta name="keywords" content="天天刮刮乐,<?php echo $webdb["vpp_jigoucode"]?>" />
<meta name="description" content="天天刮刮乐,<?php echo $webdb["vpp_jigoucode"]?>" />
<link href="../images/style.css" rel="stylesheet" type="text/css" />
<?php $head_hide=1;require("../w_head.php");?>
<style type="text/css">
.demo{width:100%; height:auto; position:relative; padding:10px auto; background:url(images/top_bg2.jpg) center top no-repeat; background-size:100%; overflow:hidden;}
.disk{width:320px; height:271px; margin:auto; background:url(images/ggl_bg.png) center top no-repeat; position:relative;}
.ggl_div{display:inline-block; position:relative; border:solid #b5b5b5 1px; width:185px; height:30px; background:#b5b5b5; position:absolute; right:20px; bottom:40px;}
.dzp_title1{ color:#FFFFFF; background:#63c2ea; line-height:200%; font-size:1.4em; text-align:center; width:95%; margin:auto; padding:0px;}
.dzp_con{ background:#17a6e0; width:95%; margin:auto; color:#FFFFFF; font-size:1.1em;-moz-border-radius:9px;-webkit-border-radius:9px; padding-bottom:10px;}
.dzp_con h1{ width:100%; background:#63c2ea; color:#006994; font-size:1.4em; text-indent:2em; line-height:200%;}
.dzp_con .con2{ width:95%; margin:auto; color:#fff43f;}
.disk_end{width:320px; height:271px; margin:auto; background:url(images/ggl_endbg.png) center top no-repeat; position:relative;}
</style>
<?php
$sql= "select * from mx_vpp_caipiao where type='3' and isok='1' and startdate<='".date("Y-m-d")."' and enddate>='".date("Y-m-d")."' order by orderid asc,createdate desc,id desc limit 1";
$rsdb= $db -> getinfo($sql);
if ($rsdb['id']<=0) {
	$sql= "select * from mx_vpp_caipiao where type='3' and isok='1' and startdate>='".date("Y-m-d")."' and enddate>='".date("Y-m-d")."' order by startdate asc,createdate desc,id desc limit 1";
	$rsdb= $db -> getinfo($sql);
}
?>
</head>
  
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="wScratchPad.js"></script>
<body>
<?php
if ($rsdb["id"]>0){
?>
<div class="demo">
	<div class="disk">
	<div id="wScratchPad4" class="ggl_div" onClick="set_ggl();"></div>
    <input type="hidden" name="isset" id="isset" value="0">
	</div>
</div>	
    <script type="text/javascript">
	function set_ggl(){
		if (document.getElementById("isset").value=="0"){
			document.getElementById("isset").value=1;
			$.ajax({ 
				type: 'POST', 
				url: 'get_guaguale.php?id=<?php echo $rsdb['id'] ?>', 
				dataType: 'json', 
				cache: false, 
				error: function(){ 
					alert('出错了！');
					document.getElementById("isset").value=0;
					return false; 
				}, 
				success:function(json){ 
					var imgstr = json.image; //角度 
					var p = json.prize; //奖项 
					var error = json.error;
					if (error != 0) {
						alert(error);
						document.getElementById("isset").value=0;
					} else {
						document.getElementById("isset").value=1;
						$("#wScratchPad4").wScratchPad({
							width:185,
							height:30,
							image:imgstr,
							scratchMove: function(e, percent)
							{
								if(percent > 0){
									this.clear();
									$("#wScratchPad4").find("canvas").attr('width','0px');
									$("#wScratchPad4").find("canvas").attr('height','0px');
									//alert(p);
									return true; 
								}
							},
						});
					} 
				} 
			}); 
		}
	}
		function set(){
			if (document.getElementById("isset").value=="0"){
//			document.getElementById("isset").value=1;
//			$("#wScratchPad4").wScratchPad({
//				cursor:'coin.gif',
//				width:100,
//				height:60,
//				image:'2.jpg',
//				scratchMove: function(e, percent)
//				{
//					if(percent > 70)
//					this.clear();
//					
//				},
//			});
			}
		}
    </script>
   <div class="clear"></div>
   <div class="height10"></div>
   <div class="lingqu"><a href="javascript:document.getElementById('isset').value=0;location.reload() ">再来一次</a></div>
   <div class="clear"></div>
   <div class="lingqu" style="margin-top:10px;"><a href="/my_cp.php">我的奖品</a></div>
   <div class="clear"></div>
   <div class="height10"></div>
   <div class="dzp_con">
   <div class="height10"></div>
   <h1>奖项设置</h1>
   <div class="height10"></div>
   <div class="clear"></div>
   <div class="con2">
   <table width="100%" cellpadding="0" cellspacing="0" align="center">
   <?php 
   $rs2=$db->excu("select * from  mx_vpp_caipiao_prize where cpid='$rsdb[id]' and isok='1' and isshowjp='1' order by orderid asc, createdate desc, id desc");
   if ($db->num_rows($rs2)>0){
   	while ($rsdb2=$db->fetch_array($rs2))
	{
   ?>
   <tr><td height="30"><?php echo $rsdb2["name"];?></td><td>奖品数量：<?php echo $rsdb2["shownum"];?></td></tr>
   <?php
	}
   }
   ?>
   </table>
   </div>
   <div class="height10"></div>
   </div>
   
   <div class="clear"></div>
   <div class="height10"></div>
   <div class="height10"></div>
   <div class="clear"></div>
   
   <div class="dzp_con">
   <div class="height10"></div>
   <h1>活动说明</h1>
   <div class="height10"></div>
   <div class="clear"></div>
   <div class="con2">
   <?php echo "每次消耗".$rsdb["needintegral"]."积分<br/>";?>
   <?php echo stripslashes($rsdb["description"]);?>
   </div>
   <div class="height10"></div>
   </div>
   
<?php }else{?>
<div class="demo">
	<div class="disk"> </div>
</div>	
  
   <div class="clear"></div>
   
   <div class="lingqu" style="margin-top:10px;"><a href="/my_cp.php">我的奖品</a></div>
   <div class="clear"></div>
   <div class="height10"></div>
   <div class="dzp_con">
   <div class="height10"></div>
   <h1>活动说明</h1>
   <div class="height10"></div>
   <div class="clear"></div>
   <div class="con2">
   活动已经结束，请及时关注我们最新的动态信息！   </div>
   <div class="height10"></div>
   </div>
<?php
}
require("../w_foot.php");
?>